import pygame
from random import *
from spritesheet import *
from pygame.locals import *

class Cactus(pygame.sprite.Sprite):
	def __init__(self, spritesheet):
		pygame.sprite.Sprite.__init__(self)
		
		random = Random()
		random.seed()
		
		self.image = pygame.surface.Surface((64, 64))
		self._images = spritesheet.get_image(Rect((0, 128), (320, 64)))
		self.rect = Rect((random.randint(0, 9) * 64, (random.randint(0, 9) * 64)), (64, 64))
		self.animation = 0
		
	def update(self):
		if self.animation < 30:
			self.animation += 1

		s_rect = Rect(((self.animation / 10) * 64, 0), (64, 64))
		self.image.blit(self._images, (0, 0), s_rect)
		self.image.set_colorkey(self.image.get_at((0, 0)), RLEACCEL)
		
	def frozen():
		self.animation = 40